import React from "react";
import { Switch } from "antd";
import { ProFormSelect } from "@ant-design/pro-components";
import type { ProFieldValueType } from "@ant-design/pro-components";

/**
 * 自定义状态切换组件
 * 在表格中显示为Switch，在搜索表单中显示为Select
 */
const switchStatus: ProFieldValueType = {
  renderFormItem: (text) => (
    <Switch
      checked={typeof text === "boolean" ? text : text === "true"}
      checkedChildren="启用"
      unCheckedChildren="禁用"
    />
  ),
  // renderFormItem: (text, props) => {
  //   return (
  //     <ProFormSelect
  //       placeholder="请选择"
  //       options={[
  //         { label: "启用", value: true },
  //         { label: "禁用", value: false },
  //       ]}
  //       {...props?.fieldProps}
  //     />
  //   );
  // },
};

export default switchStatus;
